<template>
	<div>

		<el-container class="container">
			<el-aside class="register" width="350px">
				<el-tag style="width:280px;margin-bottom: 2px;">患者列表</el-tag>
				<el-tabs type="border-card">
					<el-tab-pane label="本人">
						<RegisterList :registType="1" @selectRegister="selectRegister" :key="showNum"></RegisterList>
					</el-tab-pane>
					<el-tab-pane label="科室">
						<RegisterList :registType="2" @selectRegister="selectRegister" :key="showNum"></RegisterList>
					</el-tab-pane>
				</el-tabs>
			</el-aside>
			<el-main class="main">

				<el-tabs type="border-card" :before-leave="beforeLeave" :value ="selectTab">
					<el-tab-pane label="病历首页" name="PaperHome">
						<PaperHome :register="register" @update="updateRegister"></PaperHome>
					</el-tab-pane>
					<el-tab-pane label="检查申请" name="CheckApply">
						
						
						<CheckApply :register="register"></CheckApply>
						
						
					</el-tab-pane>
					<el-tab-pane label="检验申请" name="InspectApply">
						
						<InspectApply :register="register"></InspectApply>
							
					</el-tab-pane>
					<el-tab-pane label="治疗方案" name="Finish">
						
						<Finish :register="register"></Finish>
							
					</el-tab-pane>
					
					
				</el-tabs>






			</el-main>
		</el-container>
	</div>
</template>

<script>
	import RegisterList from '@/views/doctor/regist_list'
	import PaperHome from '@/views/doctor/paper-home'
	import CheckApply from '@/views/doctor/check-apply'
	import InspectApply from '@/views/doctor/inspect-apply'
	import Finish from '@/views/doctor/finish'
	export default {
		name: 'DoctorHome',
		components: {
			RegisterList,
			PaperHome,
			CheckApply,
			InspectApply,
			Finish
		},
		data() {
			return {
				selectTab:'PaperHome',
				showNum:0,
				register:null
			}
		},
		methods: {
			selectRegister(register){
				//病历界面接受到左侧 选中的患者
				this.register = register;
			},
			updateRegister(){
				this.showNum++;
			},
			beforeLeave(aName,oName){
				console.log(aName,oName);
				if(aName !== 'PaperHome' ){
					if( this.register == null){
						this.$message.error("请选择患者")
						return false;
					}else if(this.register.status !== 2){
						this.$message.error("请选择已接诊患者")
						return false;
					}
				}
				return true;
			}
		},
		created() {}
	}
</script>

<style scoped>
	.container {
		/* border: 1px solid red; */
		height: 100vh;
	}

	.register {
		height: 100vh;
		/* border: solid 1px red; */
	}

	.main {
		margin: 0;
		padding: 0;
	}
</style>
